﻿using Client.Processes;
using Client.ViewModels;

namespace Client.Commands
{
    public class SaveMovieCommand : BaseCommand
    {
        private SaveMovie save;

        public SaveMovieCommand(SaveMovie save)
        {
            this.save = save;
        }

        public override bool CanExecute(object parameter)
        {
            var viewModel = (parameter as WorkspaceViewModel);

            if (viewModel == null)
                return false;

            return viewModel.IsEditMode && viewModel.MovieItem != null;
        }

        public override void Execute(object parameter)
        {
            save.Process((parameter as WorkspaceViewModel).MovieItem);
        }
    }
}
